<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引用vue3的源码 -->
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <div class="app"></div>
    
</body>
<script>
    const app = Vue.createApp({
        data(){
            return{
                message:'jspang.com',
                price:10,
                count:2,
            }
        },
        //监听器,可以设置两个参数，第一个是现在的值，第二个是之前的值（名字随便
        watch:{
            count(current,preview){
                console.log('count changed');
                console.log('现在值：',current);
                console.log('之前值：',preview);
            }
        },
        computed:{
            
            total(){
                return this.price * this.count
            },
        },
        methods: {
            clickItem(){
                this.message = this.message == 'jspang.com'?'技术胖':'jspang.com'
            },
            gettotal(){
                return this.price*this.count
            },
            clickCount(){
                this.count++
            }
        },
        
        template:`
            <h2>{{message}}</h2>
            <h2>{{total}}</h2>
            <h2>{{total}}</h2>
            <button @click='clickCount'>count++</button>
        `
    })
    app.mount('.app')
</script>

</html>